package com.bolehui.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bolehui.base.result.Result;
import com.bolehui.domain.po.Internshipexperience;
import com.bolehui.domain.vo.InternshipExVO;
import com.bolehui.mapper.InternshipexperienceMapper;
import com.bolehui.service.InternshipexperienceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chendongjie
 * @since 2025-03-18
 */
@Service
public class InternshipexperienceServiceImpl extends ServiceImpl<InternshipexperienceMapper, Internshipexperience> implements InternshipexperienceService {

    @Autowired
    private InternshipexperienceMapper internshipexperienceMapper;
    @Override
    public Result saveInternship(InternshipExVO internshipExVO, Long userId) {
        Internshipexperience internshipexperience = Internshipexperience.builder()
                .companyName(internshipExVO.getCompanyName())
                .job(internshipExVO.getJob())
                .jobName(internshipExVO.getJobName())
                .jobContent(internshipExVO.getJobContent())
                .dateStart(internshipExVO.getDateStart())
                .dateEnd(internshipExVO.getDateEnd())
                .candidateId(userId)
                .build();
        internshipexperienceMapper.insert(internshipexperience);
        return Result.success();
    }

    @Override
    public Result update(InternshipExVO internshipExVO, Long userId) {
        Internshipexperience internshipexperience = Internshipexperience.builder()
                .companyName(internshipExVO.getCompanyName())
                .job(internshipExVO.getJob())
                .jobName(internshipExVO.getJobName())
                .jobContent(internshipExVO.getJobContent())
                .dateStart(internshipExVO.getDateStart())
                .dateEnd(internshipExVO.getDateEnd())
                .build();
        internshipexperienceMapper.update(internshipexperience, new QueryWrapper<Internshipexperience>().eq("candidate_id", userId));
        return Result.success();
    }
}
